<!--#include file="inc/conn.asp" -->
<!--#include file="inc/Function.asp" -->
<!--#include file="inc/pageClass.asp"-->
<%
CheckAdmin()

post_no=checkstr(trim(request("post_no")))
Action=request("Action")



    Select Case Request("Action")
		Case "Save"
             Save()
		Case "Add"
             Add()
		Case "Del"
             Del()
		Case "Lock"
             Lock()
		Case "UnLock"
             UnLock()
        Case Else 
			Main()

    End Select

'批量锁定商品
sub Lock()
		If user_no=""  OR	IsNumeric(user_no)=False Then 	response.write "{""msg"":""用户ID错误"",""status"":""no""}":response.end
If ID="" Then 
        sql="update USER_PROFILE set login_tag='N' where User_no ='"&user_no&"'"
Else
        sql="update USER_PROFILE set login_tag='N' where User_no ='"&user_no&"'"
End If 
        conn.Execute(sql)
			response.write "{""msg"":""账号封禁成功!"",""status"":""yes""}"
			response.end
end Sub



'批量解锁用户
sub UnLock()
		If user_no=""  OR	IsNumeric(user_no)=False Then 	response.write "{""msg"":""用户user_no错误"",""status"":""no""}":response.end
        sql="update USER_PROFILE set login_tag='Y'  where User_no= '"&user_no&"'"
        conn.Execute(sql)
		response.write "{""msg"":""账号解锁成功!"",""status"":""yes""}":response.end

end Sub

sub Save()


reg_qq=trim(request("reg_qq"))
user_mail=trim(request("user_mail"))
login_tag=trim(request("login_tag"))
user_id=trim(request("user_id"))
username=trim(request("username"))
vip=trim(request("vip"))
UserNote=trim(request("UserNote"))
password=trim(request("password"))

If Money="" Or  isnumeric(Money)=False Then	Money=0
If Pay_No="" Or  isnumeric(Pay_No)=False Then	Pay_No=0

If login_tag="N" Then 
login_tag="N"
Else
login_tag="Y"
End If 

If vip="1" Then 
vip=1
Else
vip=0
End If 



				if isnumeric(amount)=false   then
					response.write "{""msg"":""错误:商城币输入错误,只允许数字!"",""status"":""no""}"
					response.end
				end If




set rs=conn.execute("select login_tag from USER_PROFILE where  user_no='"&user_no&"'")

if rs("login_tag")<>login_tag then 
		If Len(UserNote)<2  Then 
			response.write "{""msg"":""错误:封号,解除封号,添加黑名单等操作必须添加说明!!"",""status"":""no""}"
			response.end
		end If
		If login_tag="Y" Then
				logtxt="解除锁定"&Note
		Else
				logtxt="锁定帐号"&Note
		End If
End If

If user_id<>username Then 
set rs=conn.execute("select user_id from USER_PROFILE where  user_id='"&user_id&"'")
		if Not(rs.eof Or rs.bof)  then 
			response.write "{""msg"":""错误:用户名已存在,请重新输入!"",""status"":""no""}"
			response.End
		Else
			logtxt="修改用户名:"&user_id
		End If
End If 



		' 发送商城币
If oldcash<>amount Then 
		set rscash=conn_b.execute("select amount from user_cash where  user_no='"&user_no&"'")
		If rscash.eof  Or rscash.bof Then 
			response.write "{""msg"":""错误:用户商城信息有误,请让该用户打开一次商城后在进行操作!"",""status"":""no""}"
			response.end
		End If 

		If session("SuperAdmin")<>1 then
				if  Len(Remark)<2   then
					response.write "{""msg"":""错误:操作备注必须仔细填写,请参考帮助信息!"",""status"":""no""}"
					response.end
				end If
		End If 








Remark="管理员:"&admin_user&Remark
If rscash(0)<>int(amount)  Then
			If  rscash(0)=0 Then 
				logtxt=logtxt&" 增加商城币:"&amount
				GameCash=amount
			Else
				logtxt=logtxt&" 修改原商城币:"&rscash(0)&" 为"&amount
				GameCash=amount-rscash(0)
			End If

			set rscash_add=conn_b.execute("update user_cash set amount="&amount&" where user_no='"&ID&"'")
Else
GameCash=0
End If 

set rspay=conn_p.execute("INSERT INTO PayLog (UserName,UserId,amount,Servicer,PayNo,Paytime,Payip,ServerId,Remark,GameCash,trade_status) VALUES ('"&username&"',"&ID&","&Money&",'"&Bank&"',"&Pay_No&",'"&Now()&"','"&GetIP&"','"&ServerName&"','"&Remark&"',"&GameCash&",3)")
End If

set rsuser=conn.execute("update USER_PROFILE set user_id='"&user_id&"',user_pwd='"&md5(password)&"',login_tag='"&login_tag&"',reg_qq='"&reg_qq&"',user_mail='"&user_mail&"' ,vip='"&vip&"',password='"&password&"' ,UserNote='"&UserNote&"' where user_no='"&ID&"'")



If Description="" Then Description="null"
	Call Add_Log(user_no,user_id,"null","null",logtxt,"1",Description)	'写日志
	Action_Str="-代码:"&logtxt&""

response.write "{""msg"":""用户"&user_id&"修改成功!"&Action_Str&""",""status"":""yes""}"
response.End



End Sub




Sub Main()
pageLink="Edit"

SET RS = Conn_c.Execute("select *  from USER_POSTBOX where post_no='"&post_no&"'")

strtitle=post_no&"-商品信息修改"


Call  head(strtitle)
If browser()="pc" Then Call  LeftMenu()
%>
  <!-- 右侧主体开始 -->
  <div class="page-content">
<%Call  mnav()%>
		<div class="weadmin-body">


		<%Call  Search()%> 
<%
									If rs("character_no")=admin_character Then
										character_name=  "SYSTEM"
										else
								  SET rsc = Conn_c.Execute("select character_name from user_character where character_no='"&rs("character_no")&"'")
									if Not rsc.eof  then 
										   character_name=  rsc(0)
										   rsc.close
									  End If 
								  End If 
									'byHeader=page("byHeader")
									'Hexinfo=ShowHex(page("info"))
		  %>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
        <div class="layui-row">
		
		<form  class="layui-form layui-form-pane">
                <div class="layui-form-item">
					<label for="user_no" class="layui-form-label">
                        <span class="x-red"></span>角色</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_no" name="user_no" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=character_name%>" readonly>
                    </div>
                    <label for="user_id" class="layui-form-label">
                        <span class="x-red"></span>post_no</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="post_no" name="post_no" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=rs("post_no")%>" readonly>
                    </div>			 <label for="user_mail" class="layui-form-label">
                        <span class="x-red"></span>发送时间</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_mail" name="user_mail" class="layui-input"  value="<%=rs("ipt_time")%>" readonly>
                    </div>
					 
		</div>			

<%
		  SET RS3 = conn_i.Execute("select itemname,itemid from Item where itemid="&rs("Windex")&"")
		   If rs3.eof Or rs3.bof Then 
		  itemname="未知"
		  Else
		  itemname=rs3(0)
		  End If 
		   rs3.close
		  Set rs3=Nothing

byHeader=rs("byHeader")
Hexinfo=ShowHex(rs("info"))


		  %>

			<div class="layui-form-item">
			<label for="password" class="layui-form-label">
                        <span class="x-red"></span>物品名称</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_id" name="user_id" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=itemname%>">
                    </div>
			<label for="reg_qq" class="layui-form-label">
                        <span class="x-red"></span>数量</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="reg_qq" name="reg_qq" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%if isChkInteger(Hexnumber(Hexinfo)) then response.write left(Hexnumber(Hexinfo),5) else response.write "1"%>">
                    </div>

				 <label for="user_mac" class="layui-form-label">
                        <span class="x-red"></span>售价</label>
                    <div class="layui-input-inline">
                       	<input  style="height: 38px;" type="text" id="user_mail" name="user_mail" class="layui-input"  value="<%=rs("dil_tag")%>">
                    </div>				 
                </div>

                <div class="layui-form-item layui-form-text"> 

                    <table  class="layui-table layui-input-block">
                        <tbody>
                            <tr>
                                <td width="100" height="35"> 
                                    商品标题
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value="<%=rs("post_title")%>"style="WIDTH: 380px"></div>		
                                </td>
                            </tr>
							<tr>
                                <td width="100" height="35"> 
                                    商品介绍
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value="<%=rs("body_text")%>"style="WIDTH: 380px"></div>		
                                </td>
                            </tr>
							<tr>
                                <td>
								属性
                                </td>
                                <td><%=itemoption(Hexinfo,byHeader)%></td> 
                            </tr>
                           		 <tr>
                                <td height="35">
								属性值
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value="<%=Hexinfo%>"style="WIDTH: 380px"></div>		
								 <input name="上架" type="checkbox" id="vip" value="1"  class="layui-input" title="上架" <%If 1=1 then response.write "checked"%> class="checkbox">
										<input name="username" type="hidden" value="user_id">
										<input name="oldcash" type="hidden" id="oldcash" value="<%=amount%>">
										<button class="layui-btn layui-btn-normal layui-btn-sm"  lay-submit="" lay-filter="add">修改信息</button>
                                </td> 
                            </tr>
                           </tbody>
                    </table>
                </div>

            </form>
        </div>
    </div>
    </div>



<%
End Sub
conn.Close
Set conn = Nothing

Sub Add()
pageLink="Add"
character_name=  "SYSTEM"
strtitle="添加道具"


Call  head(strtitle)
If browser()="pc" Then Call  LeftMenu()
%>
  <!-- 右侧主体开始 -->
  <div class="page-content">
<%Call  mnav()%>
		<div class="weadmin-body">


		<%Call  Search()%> 

<div class="layui-fluid">
<div class="layui-row layui-col-space15">
        <div class="layui-row">
		
		<form  class="layui-form layui-form-pane">
                <div class="layui-form-item">
					<label for="user_no" class="layui-form-label">
                        <span class="x-red"></span>角色</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_no" name="user_no" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=character_name%>">
                    </div>
                    <label for="user_id" class="layui-form-label">
                        <span class="x-red"></span>物品名称</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="post_no" name="post_no" required="" lay-verify="required" autocomplete="off" class="layui-input" value="">
                    </div>
					
					<label for="user_mail" class="layui-form-label">
                        <span class="x-red"></span>物品ID</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_mail" name="user_mail" class="layui-input"  value="">
                    </div>
					 
		</div>			


			<div class="layui-form-item">
			<label for="password" class="layui-form-label">
                        <span class="x-red"></span>发送时间</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="user_id" name="user_id" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=now()%>">
                    </div>
			<label for="reg_qq" class="layui-form-label">
                        <span class="x-red"></span>数量</label>
                    <div class="layui-input-inline">
                        <input  style="height: 38px;" type="text" id="reg_qq" name="reg_qq" required="" lay-verify="required" autocomplete="off" class="layui-input" value="">
                    </div>

				 <label for="user_mac" class="layui-form-label">
                        <span class="x-red"></span>售价</label>
                    <div class="layui-input-inline">
                       	<input  style="height: 38px;" type="text" id="user_mail" name="user_mail" class="layui-input"  value="10">
                    </div>				 
                </div>

                <div class="layui-form-item layui-form-text"> 

                    <table  class="layui-table layui-input-block">
                        <tbody>
                            <tr>
                                <td width="100" height="35"> 
                                    商品标题
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value=""style="WIDTH: 380px"></div>		
                                </td>
                            </tr>
							<tr>
                                <td width="100" height="35"> 
                                    商品介绍
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value=""style="WIDTH: 380px"></div>		
                                </td>
                            </tr>
							<tr>
                                <td>
								属性
                                </td>
                                <td><%=itemoption(Hexinfo,byHeader)%></td> 
                            </tr>
                           		 <tr>
                                <td height="35">
								属性值
                                </td>
                                <td>
									<div class="layui-inline layui-show-xs-block"><INPUT  name=amount id="amount" class="layui-input" value="<%=Hexinfo%>"style="WIDTH: 380px"></div>		
								 <input name="上架" type="checkbox" id="vip" value="1"  class="layui-input" title="上架" <%If 1=1 then response.write "checked"%> class="checkbox">
										<input name="username" type="hidden" value="user_id">
										<input name="oldcash" type="hidden" id="oldcash" value="<%=amount%>">
										<button class="layui-btn layui-btn-normal layui-btn-sm"  lay-submit="" lay-filter="add">添加商品</button>
                                </td> 
                            </tr>
                           </tbody>
                    </table>
                </div>

            </form>
        </div>
    </div>
    </div>



<%
End Sub

%>
		</div>
  </div>
  <%Call  footer%>
<script>
//监听提交
layui.use('form', function(){
  var form = layui.form;
    form.on('submit(add)', function(data){
    // layer.msg(JSON.stringify(data.field));//弹出json格式所有表单的值
	//return false;
    $.ajax({
      type:"get",
       url:"User_edit.asp?Action=Save",
	  data: data.field,
      dataType:"json",
      success:function(data){
        if(data.status=='yes'){
          layer.msg(data.msg, {icon: 1});
          //var url = "{:U('device/getinfo')}"; //成功跳转的url
          //setTimeout(window.location.href=url,2000);
        }else{
          layer.msg(data.msg, {icon: 2});
        }
      },
    });
	return false;
  });
});
</script>    

</body>
</html>